package xuegao.study.mall.admin.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xuegao.study.mall.admin.feign.UmsDepartmentClient;
import xuegao.study.mall.common.api.CommonResult;
import xuegao.study.mall.common.model.ums.UmsDepartment;
import xuegao.study.mall.common.vo.ums.UmsDepartmentVo;

import java.util.List;

@Api(tags = "UmsDepartmentController")
@Tag(name = "UmsDepartmentController", description = "部门管理相关接口")
@RestController
@RequestMapping(value = "/department")
public class UmsDepartmentController {

    @Autowired
    private UmsDepartmentClient umsDepartmentClient;

    @ApiOperation("部门保存")
    @PostMapping(value = "/save")
    public CommonResult<String> save(@RequestBody UmsDepartment department) {
        return umsDepartmentClient.save(department);
    }

    @ApiOperation("部门查询")
    @GetMapping(value = "/list")
    public CommonResult<List<UmsDepartmentVo>> list() {
        return umsDepartmentClient.list();
    }

    @ApiOperation("部门删除")
    @DeleteMapping(value = "/delete/{id}")
    public CommonResult<Boolean> delete(@PathVariable Long id) {
        return umsDepartmentClient.delete(id);
    }

    @ApiOperation("部门修改")
    @PostMapping(value = "/update")
    CommonResult<Boolean> update(@RequestBody UmsDepartment department) {
        return umsDepartmentClient.update(department);
    }
}
